﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Algorithm.Easy_589_Preorder
{
    public class Node
    {
        public int val;
        public IList<Node> children;

        public Node() { }

        public Node(int _val)
        {
            val = _val;
        }

        public Node(int _val, IList<Node> _children)
        {
            val = _val;
            children = _children;
        }
    }
    class MainProject
    {
        static void Main(string[] args)
        {
            //Console.WriteLine(Preorder("RDD"));
            Console.ReadKey();
        }
        public static IList<int> Preorder(Node root)
        {
            //递归
            IList<int> list = new List<int>();
            Preamble(list, root);
            return list;
        }

        private static void Preamble(IList<int> list, Node node)
        {
            list.Add(node.val);
            for (int i = 0; i < node.children.Count; i++) Preamble(list, node.children[i]);
        }
    }
}
